﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using FamilyJobsUI.DB1;
using FamilyJobsUI.Extensions;

namespace FamilyJobsUI.api
{
    public class UserPointsController : ApiController
    {
        private DB1.FamilyJobsDB db = new DB1.FamilyJobsDB();

        // GET api/<controller>
        [Route("api/UserPoints/GetUsers")]
        [AllowAnonymous]
        [HttpGet]
        public IEnumerable<Models.UsersEditModel> GetUsers()
        {
            var rawUsers = db.T_Users;

            var userEditModelList = rawUsers
                .Project().To<Models.UsersEditModel>();

            return userEditModelList.AsEnumerable();

            //return new string[] { "value1", "value2" };
        }

        [Route("api/UserPoints/GetUserPoints")]
        [AllowAnonymous]
        [HttpGet]
        public IEnumerable<FamilyJobsUI.Models.UserPoints_Index_RowModel> GetUserPoints()
        {
            var controller = new FamilyJobsUI.Controllers.UserPointsController();
            var userPoints = controller.getUserPointsList();
            return userPoints;
        }



        // GET api/<controller>/5
        public string Get(int id)
        {
            return "value";
        }

        // POST api/<controller>
        public void Post([FromBody]string value)
        {
        }

        // PUT api/<controller>/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/<controller>/5
        public void Delete(int id)
        {
        }
    }
}